home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
program
/
progem.lzh
/
apndx13.prf
< prev
next >
Wrap
Text File
|
1987-06-23
|
26KB
|
1,193 lines
.!****************************************************************************
.!
.! ANTIC PUBLISHING INC., COPYRIGHT 1985. REPRINTED BY PERMISSION.
.!
.! ** Professional GEM ** by Tim Oren
.!
.! Proff File by ST enthusiasts at
.! Case Western Reserve University
.! Cleveland, Ohio
.! uucp : decvax!cwruecmp!bammi
.! csnet: bammi@case
.! arpa : bammi%case@csnet-relay
.! compuserve: 71515,155
.!
.!****************************************************************************
.!
.! Begin Appendix XIII
.!
.!***************************************************************************
.!
.!
.AP XIII Sample Code for Part XVII
/*** rsconv.h ***/
#define MODE 0 /* TREE */
#define N2F 7 /* OBJECT in TREE #0 */
#define F2N 8 /* OBJECT in TREE #0 */
#define DEF2 15 /* OBJECT in TREE #0 */
#define HELPMODE 21 /* OBJECT in TREE #0 */
#define CONVMODE 22 /* OBJECT in TREE #0 */
#define QUITMODE 23 /* OBJECT in TREE #0 */
#define NODEF 0 /* STRING */
#define DEFYES 18 /* OBJECT in TREE #0 */
#define DEFNO 19 /* OBJECT in TREE #0 */
#define HELP 1 /* TREE */
#define NOMEM 1 /* STRING */
#define DFNYES 20 /* OBJECT in TREE #0 */
#define DEF1 13 /* OBJECT in TREE #0 */
#define RSC1 10 /* OBJECT in TREE #0 */
#define RSC2 12 /* OBJECT in TREE #0 */
#define PROGRESS 2 /* TREE */
#define STRINGS 3 /* TREE */
#define PLINE 2 /* OBJECT in TREE #2 */
#define IMGALIGN 2 /* OBJECT in TREE #3 */
#define RSCREAD 1 /* OBJECT in TREE #3 */
#define BYTESWAP 3 /* OBJECT in TREE #3 */
#define RSCWRITE 4 /* OBJECT in TREE #3 */
#define DEFREAD 5 /* OBJECT in TREE #3 */
#define DEFWRITE 6 /* OBJECT in TREE #3 */
.bp
/*** rscvmain.c **/
/*------------------------------*/
/* includes */
/*------------------------------*/
#include "portab.h" /* portable coding conv */
#include "machine.h" /* machine depndnt conv */
#include "obdefs.h" /* object definitions */
#include "gembind.h" /* gem binding structs */
#include "osbind.h" /* BDOS definitions */
#include "gemdefs.h"
#include "rsconv.h"
/*------------------------------*/
/* defines */
/*------------------------------*/
#define NIL -1
#define DESK 0
#define ARROW 0
#define HOUR_GLASS 2
#define END_UPDATE 0
#define BEG_UPDATE 1
typedef struct memform
{
WORD *mp;
WORD fwp;
WORD fh;
WORD fww;
WORD ff;
WORD np;
WORD r1;
WORD r2;
WORD r3;
} MFDB;
/*------------------------------*/
/* Global */
/*------------------------------*/
GLOBAL WORD gl_apid;
GLOBAL WORD contrl[11]; /* control inputs */
GLOBAL WORD intin[80]; /* max string length */
GLOBAL WORD ptsin[256]; /* polygon fill points */
GLOBAL WORD intout[45]; /* open workstation output */
GLOBAL WORD ptsout[12];
GLOBAL WORD gl_wchar; /* character width */
GLOBAL WORD gl_hchar; /* character height */
GLOBAL WORD gl_wbox; /* box (cell) width */
GLOBAL WORD gl_hbox; /* box (cell) height */
GLOBAL WORD gem_handle; /* GEM handle */
GLOBAL WORD vdi_handle; /* VDI handle */
GLOBAL WORD work_out[57]; /* open virt workstation values */
GLOBAL GRECT scrn_area; /* scrn area */
GLOBAL MFDB scrn_mfdb; /* scrn memory def'n for blt */
GLOBAL GRECT full; /* desktop size */
.bp
/*------------------------------*/
/* External */
/*------------------------------*/
EXTERN WORD desel_obj();
/*------------------------------*/
/* Local */
/*------------------------------*/
MLOCAL WORD native_in = TRUE; /* TRUE: input .RSC is native */
/* FALSE: input .RSC is foreign */
MLOCAL WORD conv_def = TRUE; /* TRUE: convert .DEF also */
MLOCAL WORD new_dfn = FALSE; /* TRUE: use new symbol fmt */
MLOCAL BYTE old_rsc[4] = "RSC"; /* new resource file extent */
MLOCAL BYTE new_rsc[4] = "RS2"; /* new resource file extent */
MLOCAL BYTE old_def[4] = "DEF"; /* new definition file extend */
MLOCAL BYTE new_def[4] = "DF2"; /* new definition file extend */
MLOCAL BYTE r_file[81]; /* resource file name */
MLOCAL BYTE d_file[81]; /* definition file name */
MLOCAL BYTE r2_file[81]; /* output resource name */
MLOCAL BYTE d2_file[81]; /* output definition name */
MLOCAL WORD r_hndl = -1; /* resource file handle */
MLOCAL WORD d_hndl = -1; /* definition file handle */
MLOCAL WORD r2_hndl = -1; /* output resource handle */
MLOCAL WORD d2_hndl = -1; /* output definition handle */
MLOCAL LONG f_err; /* file error */
MLOCAL BYTE *head; /* location of buffer */
MLOCAL LONG buff_size; /* size of buffer */
MLOCAL BYTE buff[20]; /* def file work area */
MLOCAL UWORD img_offset, addr; /* for image fixup */
MLOCAL WORD img_odd; /* image fixup needed? */
MLOCAL GRECT prog_rect; /* rectangle for prog indicator */
.bp
/*------------------------------*/
/* swap_bytes */
/*------------------------------*/
VOID
swap_bytes(where, len)
BYTE *where;
WORD len;
{
BYTE swap;
for (; len > 0; len -= 2)
{
swap = *where;
*where = *(where + 1);
*(where + 1) = swap;
where += 2;
}
}
/*------------------------------*/
/* swap_words */
/*------------------------------*/
VOID
swap_words(where, len)
WORD *where;
WORD len;
{
UWORD swap;
for (; len > 0; len -= 4)
{
swap = *where;
*where = *(where + 1);
*(where + 1) = swap;
where += 2;
}
}
.bp
/*------------------------------*/
/* swap_images */
/*------------------------------*/
VOID
swap_images()
{
BITBLK *where;
ICONBLK *where2;
BYTE *taddr;
WORD num;
WORD wb, hl;
where = (BITBLK *) (head + ((RSHDR *) head)->rsh_bitblk);
num = ((RSHDR *) head)->rsh_nbb;
for (; num--; where++)
{
taddr = where->bi_pdata;
wb = where->bi_wb;
hl = where->bi_hl;
if ((LONG) taddr != -1L)
{
if (img_odd)
where->bi_pdata = ++taddr;
swap_bytes(head + taddr, wb * hl);
}
}
where2 = (ICONBLK *) (head + ((RSHDR *) head)->rsh_iconblk);
num = ((RSHDR *) head)->rsh_nib;
for (; num--; where2++)
{
wb = (where2->ib_wicon + 7) >> 3;
hl = where2->ib_hicon;
taddr = where2->ib_pdata;
if ((LONG) taddr != -1L)
{
if (img_odd)
where2->ib_pdata = ++taddr;
swap_bytes(head + taddr, wb * hl);
}
taddr = where2->ib_pmask;
if ((LONG) taddr != -1L)
{
if (img_odd)
where2->ib_pmask = ++taddr;
swap_bytes(head + taddr, wb * hl);
}
}
}
.bp
/*------------------------------*/
/* swap_trees */
/*------------------------------*/
VOID
swap_trees()
{
BYTE *where;
WORD size;
where = head + ((RSHDR *) head)->rsh_trindex;
size = ((RSHDR *) head)->rsh_ntree * sizeof(LONG);
swap_bytes(where, size);
swap_words((WORD *) where, size);
}
/*------------------------------*/
/* swap_objs */
/*------------------------------*/
VOID
swap_objs()
{
OBJECT *where;
WORD num;
where = (OBJECT *) (head + ((RSHDR *) head)->rsh_object);
num = ((RSHDR *) head)->rsh_nobs;
swap_bytes((BYTE *) where, num * sizeof(OBJECT));
for (; num--; where++)
swap_words((WORD *) &where->ob_spec, sizeof(LONG));
}
.bp
/*------------------------------*/
/* swap_teds */
/*------------------------------*/
VOID
swap_teds()
{
TEDINFO *where;
WORD num;
where = (TEDINFO *) (head + ((RSHDR *) head)->rsh_tedinfo);
num = ((RSHDR *) head)->rsh_nted;
swap_bytes((BYTE *) where, num * sizeof(TEDINFO));
for (; num--; where++)
{
swap_words((WORD *) &where->te_ptext, sizeof(LONG));
swap_words((WORD *) &where->te_ptmplt, sizeof(LONG));
swap_words((WORD *) &where->te_pvalid, sizeof(LONG));
}
}
/*------------------------------*/
/* swap_ibs */
/*------------------------------*/
VOID
swap_ibs()
{
ICONBLK *where;
WORD num;
where = (ICONBLK *) (head + ((RSHDR *) head)->rsh_iconblk);
num = ((RSHDR *) head)->rsh_nib;
swap_bytes((BYTE *) where, num * sizeof(ICONBLK));
for (; num--; where++)
{
swap_words((WORD *) &where->ib_pdata, sizeof(LONG));
swap_words((WORD *) &where->ib_pmask, sizeof(LONG));
swap_words((WORD *) &where->ib_ptext, sizeof(LONG));
}
}
.bp
/*------------------------------*/
/* swap_bbs */
/*------------------------------*/
VOID
swap_bbs()
{
BITBLK *where;
WORD num;
where = (BITBLK *) (head + ((RSHDR *) head)->rsh_bitblk);
num = ((RSHDR *) head)->rsh_nbb;
swap_bytes((BYTE *) where, num * sizeof(BITBLK));
for (; num--; where++)